/**
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @param {number} k
 * @return {number}
 */
var kthLargest = function (root, k) {
	// 判空
	if (!root) {
		return null;
	}
	// 反中序遍历
	let num = 0, res;
	const inverseTraversal = (node) => {
		if (node === null) {
			return;
		}
		inverseTraversal(node.right);
		num++;
		if (num === k) {
			res = node.val;
			return;
		}
		inverseTraversal(node.left);
	}
	inverseTraversal(root);
	return res;
};